import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '姓名',
    dataIndex: 'name',
  },
  {
    title: '公司名称',
    dataIndex: 'company',
  },
  {
    title: '邮箱',
    dataIndex: 'email',
  },
  {
    title: '电话号码',
    dataIndex: 'phone',
  },
  {
    title: '申请产品模块',
    width: 200,
    dataIndex: 'products',

    customRender: ({ record }) => {
      let products = record.products || '';
      // 基础替换
      products = products.replace('1:on', '安芯神甲智能内存保护系统');
      products = products.replace('2:on', '系统信息检测工具');
      products = products.replace('3:on', '未知威胁文件检测系统');

      // 根据国家/地区字段判断替换
      if (!record.country) {
        // 对应StringUtils.isEmpty逻辑
        products = products.replace('4:on', '安芯神鉴终端保护系统');
        products = products.replace('5:on', '应用安全防护系统RASP');
      } else {
        products = products.replace('4:on', 'Mobile Device Management');
        products = products.replace('5:on', 'Managed Security Service');
      }
      return products;
    },
  },
  // {
  //   title: '国家/地区',
  //   dataIndex: 'country',
  // },
  {
    title: '客户端IP',
    dataIndex: 'ip',
  },
  // {
  //   title: '申请类型',
  //   dataIndex: 'gtype',
  // },
  // {
  //   title: '来源URL',
  //   dataIndex: 'ref',
  // },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '公司名称',
    field: 'company',
    component: 'Input',
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '公司名称',
    field: 'company',
    component: 'Input',
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '姓氏',
    field: 'lastName',
    component: 'Input',
  },
  {
    label: '名',
    field: 'firstName',
    component: 'Input',
  },
  {
    label: '电话号码',
    field: 'phone',
    component: 'Input',
  },
  {
    label: '申请产品模块',
    field: 'products',
    component: 'Input',
  },
  {
    label: '国家/地区',
    field: 'country',
    component: 'Input',
  },
  {
    label: '客户端IP',
    field: 'ip',
    component: 'Input',
  },
  {
    label: '申请类型',
    field: 'gtype',
    component: 'Input',
  },
  {
    label: '来源URL',
    field: 'ref',
    component: 'Input',
  },
];
